﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wizard.Asp
{
	public class AspEngine : Wizard.IWizardEngine, Wizard.Runtime.IPlugin
	{
		const string VERSION = "0.1";
        private System.Web.HttpApplication mHttpApplication;
        private Wizard.ICompilerEngine mCompilerEngine;
        private Wizard.IDataStore mDataStore;
        private Wizard.IRuntimeEngine mRuntimeEngine;

        public AspEngine(System.Web.HttpApplication httpApplication)
        {
            mHttpApplication = httpApplication;
            mDataStore = new Wizard.MsSql.DataStore();
            mCompilerEngine = new Wizard.Compiler.CompilerEngine();
            mRuntimeEngine = new Wizard.Runtime.RuntimeEngine();

            mRuntimeEngine.RegisterPlugin(mDataStore);
            mRuntimeEngine.RegisterPlugin(mCompilerEngine);
            mRuntimeEngine.RegisterPlugin(mRuntimeEngine);
            mRuntimeEngine.RegisterPlugin(this);
            mRuntimeEngine.InitializePlugins(this);
        }

		public string Version
		{
			get { return VERSION; }
		}

        //protected override bool AcceptPlugin(string pluginName)
        //{
        //    throw new NotImplementedException();
        //}

        //protected override void MethodIsWaitingForUser(Wizard.Runtime.StatementArgs runContext)
        //{
        //    throw new NotImplementedException();
        //}

        //protected override void MethodIsFinished(Wizard.Runtime.StatementArgs runContext)
        //{
        //    throw new NotImplementedException();
        //}

        //protected override void MethodIsClosed(Wizard.Runtime.StatementArgs runContext)
        //{
        //    throw new NotImplementedException();
        //}

        //public override string FriendlyName
        //{
        //    get { throw new NotImplementedException(); }
        //}

        //protected override string InternalGetPluginFolder()
        //{
        //    return null;
        //}


        #region IWizardEngine Members

        public Wizard.IDataStore DataStore
        {
            get { return mDataStore; }
        }

        public Wizard.ICompilerEngine CompilerEngine
        {
            get { return mCompilerEngine; }
        }

        public Wizard.IRuntimeEngine RuntimeEngine
        {
            get { return mRuntimeEngine; }
        }

        #endregion

        #region IPlugin Members

        string Wizard.Runtime.IPlugin.FriendlyName
        {
            get { throw new NotImplementedException(); }
        }

        void Wizard.Runtime.IPlugin.Load()
        {
        }

        void Wizard.Runtime.IPlugin.Initialize(IWizardEngine engine)
        {            
        }

        #endregion
    }
}
